#ifndef PID_CONTROLLER_HPP
#define PID_CONTROLLER_HPP

#include <cmath>
#include <algorithm>

struct PIDParams {
    float kp = 1.0f;
    float ki = 0.0f;
    float kd = 0.0f;
    float output_limit_min = -1.0f;
    float output_limit_max = 1.0f;
    float integral_limit = 1.0f;
};

class PIDController {
public:
    explicit PIDController(const PIDParams& params = PIDParams());
    
    float calculate(float current, float target, float dt);
    void reset();
    void updateParams(const PIDParams& params);
    
private:
    PIDParams params_;
    float previous_error_;
    float integral_;
    float last_output_;
};

#endif // PID_CONTROLLER_HPP